/**
 * 图片类
 */
export interface IImageTools {
  getImageBase64: Function
}

const ImageTools: IImageTools = {
  /**
   * 图片获取base64
   * @param imageFile 图片文件（input:file 类型上传的文件）
   */
  getImageBase64(imageFile: File): Promise<String> {
    let imgFile = new FileReader()
    imgFile.readAsDataURL(imageFile)
    return new Promise((resolve: any) => {
      imgFile.onload = function () {
        let result: any = this.result
        let img = new Image()
        img.src = result
        img.onload = function () {
          resolve(result)
        }
      }
    })
  }
}

export default ImageTools